#!/bin/bash

############################################################################
#
# 远程执行该脚本，请在命令行中直接执行以下命令：
#
#   curl -sSL https://gitee.com/tay3223/biubiubiu/raw/master/centos7-install-snapd.sh | /bin/bash
#
#
############################################################################


yum install epel-release -y
yum install snapd -y

systemctl start snapd.socket
systemctl status snapd.socket
#systemctl enable snapd.socket

systemctl start snapd.service
systemctl status snapd.service
#systemctl enable snapd.service

ln -sf /var/lib/snapd/snap /snap
snap version




yum remove certbot -y
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot


cat << \EOF

====================================

官网：https://certbot.eff.org/instructions?ws=nginx&os=centosrhel7


第一步：先把nginx配置给编写好，要求server_name要在nginx上存在（这里就预先自行安装好nginx，并写好配置文件）
server{
  listen 80;
  server_name gitlab.taycc.com;

  location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass  http://127.0.0.1:9080;
  }
}


第二步：要把域名指向到这个nginx入口（如果有泛解析的话，可以忽略该步骤）

第三步：开始签订证书
    certbot --nginx

第四步：自动续订
    certbot renew --dry-run

====================================

EOF
